import React from 'react';
import { useModel } from 'umi';
// 解决有文字的情况
const AuthComponents: React.FC<{
  children: any;
  name: string;
}> = ({ name, children }) => {
  const { key } = useModel('stepModel');
  const authList = Array.isArray(key)
    ? key
    : Object.values(key || {})
        .flat()
        .map((item) => item.key) || [];
  return <React.Fragment>{authList.includes(name) ? children : null}</React.Fragment>;
};

export default AuthComponents;
